
<?php include './application/views/top.php'; ?>
<script src="/resource/js/circle-progress.js"></script>
<div class="clear h30"></div>
                    

<div class="layout diya">
	<!-- S 标题 -->
	<div class="title">
    	<i class="t0"></i>
        <s><?php echo $borrow_type_html_arr[$borrow['ftype']];?></s>
		<h3><?php echo $borrow['title'];?></h3>
        <span></span>
    </div>
	<!-- E 标题 -->
    <div class="content">
    	<!-- S 左 -->
        <div class="left">
            <ul class="tbt">
              <li class="xmxq"><span>项目总金额（元）</span></li>
                <li class="nhsy">年化收益率</li>
                <li class="xmje">还款期限</li>
                <li class="bzfs">投资奖励</li>
                <li class="qx">还需金额</li>
                <li class="jd">投资进度</li>
            </ul>
            <ul class="tbc">
                <li class="xmxq"><span class="c_dx">&yen;<?php echo number_format($borrow['account'],2);?></span></li>
                <li class="nhsy"><span><b><?php echo $borrow['apr'];?></b>%</span></li>
                <li class="xmje"><span><?php echo $borrow['is_day']==1?$borrow['time_limit_day']:$borrow['time_limit'];?><?php echo $borrow['is_day']==1?'天':'个月';?></span></li>
                
                <li class="bzfs"><span><?php echo $borrow['funds'];?>%</span></li>
                <li class="qx"><i>&yen;<?php echo round($borrow['account']-$borrow['account_yes'],2);?></i></li>
                <li class="jd">
                	<div class="circle xq1" style="margin-top:20px;"><strong></strong></div>
                    <script>yuan("xq1",<?php echo ($borrow['account_yes']/$borrow['account']);?>,<?php echo ($borrow['account_yes']/$borrow['account'])*100;?>);</script>
				</li>
            </ul>
            <ul class="tbt">
              <li class="xmxq"><span>还款方式</span></li>
                <li class="nhsy">借款用途</li>
                <li class="xmje">剩余时间</li>
                <li class="bzfs">最小投标金额</li>
                <li class="qx">最大投标金额</li>
                <li class="jd"></li>
            </ul>
            <ul class="tbc nb">
                <li class="xmxq"><span class="ziti"><?php echo $borrow['style'] == 0?'等额本息':'按月付息,到期还本';?></span></li>
                <li class="nhsy"><span><?php echo $borrow_fuse_type[$borrow['fuse']];?></span></li>
                <li class="xmje">
<dt>
                    <span style="display: none;color:#c62721; font-size:14px;" id="remainSeconds">
                            <?php
                            $remain_time = $borrow['verify_time']+$borrow['valid_time'] * 3600 * 24 - time();
                            echo $remain_time>0?$remain_time:1;
                            ?></span></dt>
                            <dt id="remainTime" style="color:#c62721; font-size:14px;"></dt>
                
				</li>
                <li class="bzfs"><span><?php echo $borrow['lowest_account'];?>元</span></li>
                <li class="qx"><span><?php echo $borrow['most_account'] > 0 ? "{$borrow['most_account']}元" : "未限制" ;?></span></li>
                <li class="jd"></li>
            </span></li>
            </ul>
        </div>
        <div class="right">
			<div class="text">
			<?php if ($borrow['account_yes'] < $borrow['account'] && in_array($borrow['fstatus'], array(1,3))){?>
				<form id="investFrom" action="" method="post">
				<input type="hidden" name="id" id="bid" value="<?php echo $borrow['id'];?>">
            	<h4>可用余额：</h4><span><?php echo number_format($user_account['use_money'],2);?>元</span>
                <?php if( strtotime($borrow['open_time'])<time() ){
						$endTime = $borrow['verify_time']+$borrow['valid_time'] * 3600 * 24;
				if(time()<$endTime){?>
				<h4>投标金额：</h4><span><input type="text" id="account" name="account" /></span>
                
				<?php if ($borrow['is_dxb']==1){?>
                <h4>定向密码：</h4>
				<?php if($borrow['user_id'] == $user_id) {?>
                <span><?php echo $borrow['dxb_pwd'];?></span>
				<?php } else {?>
                <span><input type="text" id="dxb_pwd" name="dxb_pwd"></span>
				<?php }?>
				<?php }?>
				
				<?php if($tuser_account['paypassword'] == ""){?>
                <h4 class="yellow"><a href="../../user/paypwd.html">设置支付密码</a></h4>
				<?php }else{?>
                 <h4 class="yellow">支付密码：</h4>
                 <span><input type="password" id="paypassword" name="paypassword"></span>
				<?php }?>
                
				<?php }?>
				<?php }?>
				<?php if(strtotime($borrow['open_time'])<time()){
				if(time()<$endTime){?>
                <span class="cb"><a href="javascript:void(0);" onclick="invest();" class="server_an">立即投标</a></span>
				<?php }else{?>
                <span class="cb"><a href="javascript:void(0);" class="server_an" style="background-color: #d1d1d1;">已过期</a></span>
				<?php }?>
				<?php }else{?>
                <span class="cb"><a href="javascript:void(0);" class="server_an" style="background-color: #ff6600;">即将开放</a></span>
				<?php }?>
	            </form>
			<?php }else{ ?>
            	<h4>投资人数：</h4>
                <span><i style="color:#a71e32;"><?php echo $borrow['tender_times'];?></i> 人</span>
                <?php if($borrow['ftype'] != 4){?>
				<?php if($borrow['fstatus'] == 3 && $borrow['repayment_account'] <= $borrow['repayment_yesaccount']){?>
                <span class="cb"><a href="javascript:void(0);" class="server_an" style="background-color: #d1d1d1;">已完成</a></span>
                <?php }elseif($borrow['fstatus'] == 3 && $borrow['repayment_account'] > $borrow['repayment_yesaccount']){?>
                <span class="cb"><a href="javascript:void(0);" class="server_an" style="background-color: #d1d1d1;">还款中</a></span>
                <?php }elseif($borrow['fstatus'] == 1 && $borrow['account'] <= $borrow['account_yes']){?>
                <span class="cb"><a href="javascript:void(0);" class="server_an" style="background-color: #d1d1d1;">复审中</a></span>
                <?php }?>
                <?php }else{?>
                <?php if($borrow['account'] <= $borrow['account_yes'] && (($borrow['lz_endtime']+24*60*60) > time())){?>
                <span class="cb"><a href="javascript:void(0);" class="server_an" style="background-color: #d1d1d1;">还款中</a></span>
                <?php }elseif ($borrow['lz_endtime'] < time() && $borrow['account_yes'] == 0){?>
                <span class="cb"><a href="javascript:void(0);" class="server_an" style="background-color: #d1d1d1;">复审中</a></span>
                <?php }?>
                <?php }?>
            <?php }?>
            </div>

        </div>
	</div>
</div>
<div class="clear h30"></div>
<div class="layout project">
	<ul id="tab-list-li" class="menu">
		<li class="cut" onclick="changeTab(this)"><h3>项目详情</h3></li>
		<li onclick="changeTab(this)"><h3>账户详情</h3></li>
		<li onclick="changeTab(this)"><h3>投标记录</h3></li>
	</ul>
    <div class="content linksQWap">      
		<div class="xiangmu tab-con">
            <div>
                <h5 class="bt">资料证明：</h5>
                <a class="left"></a>
                <a class="right"></a>
                <ul>
				<?php foreach($user_attestation as $attestation){?>
				<li><a href="/<?php echo $attestation['litpic'];?>" rel="lightbox[roadtrip]" target="_blank"><img src="/<?php echo $attestation['litpic'];?>"  width="80" height="80" /></a></li>
				<?php }?>   
                </ul>
            </div>
            <div>
                <h5><?php echo $user_obj['card_type']==5 ? '企业信息':'个人资料';?>：</h5>
                <?php if ($user_obj['card_type']==5){?>
                <span class="bb">企业性质：<?php echo isset($user_info['company_type']) && $user_info['company_type'] ? $linkage[$user_info['company_type']]['fvalue'] : '-';?></span>
                <span>注册时间：<?php echo $user_obj['birthday'] ? date('Y-m-d', $user_obj['birthday']):'-';?></span>
                <span>注册资金：<?php echo isset($user_info['zhuce']) ? $user_info['zhuce'] : '-';?></span>
                <span>企业规模：<?php echo isset($user_info['company_employee']) ? $user_info['company_employee']: '-';?></span>
                <span>经营范围：<?php echo isset($user_info['fanwei']) ? utf8substr($user_info['fanwei'],0,9) : '-';?></span>
                <span>年检情况：<?php echo isset($user_info['nianjian']) ? $user_info['nianjian'] : '-';?></span>
                <?php }else{?>
                <span class="bb">性 别：<?php if($user_obj['sex'] == 1){echo '男';}elseif($user_obj['sex'] == 2){echo '女';}else{echo '-';}?></span>
                <span>每月收入：<?php echo isset($user_info['income']) && $user_info['income'] ? $linkage[$user_info['income']]['fvalue'] : '-';?></span>
                <span>婚姻情况：<?php echo isset($user_info['marry']) && $user_info['marry'] ? $linkage[$user_info['marry']]['fvalue'] : '-';?></span>
                <span>年 龄：<?php echo $user_obj['birthday'] ? date('Y-m-d', $user_obj['birthday']):'-';?></span>
                <span>住房条件：<?php echo isset($user_info['house']) && $user_info['house'] ? $linkage[$user_info['house']]['fvalue'] : '-';?></span>
                <span>是否购车：<?php echo isset($user_info['car']) && $user_info['car'] ? $linkage[$user_info['car']]['fvalue'] : '-';?></span>
                <?php }?>
            </div>
            <div>
                <h5>项目介绍：</h5>
                <span class="bb"><?php echo $borrow['content'];?></span>
            </div>
            <?php if (trim($borrow['repay_from'])!=''){?>
            <div>
                <h5>还款来源：</h5>
                <span class="bb"><?php echo $borrow['repay_from'];?></span>
            </div>
            <?php }?>
            <?php if (trim($borrow['risk_manage'])!=''){?>
            <div>
                <h5>风控措施：</h5>
                <span class="bb"><?php echo $borrow['risk_manage'];?></span>
            </div>
            <?php }?>
            <?php if (trim($borrow['publish_remark'])!=''){?>
            <div>
                <h5>发布说明：</h5>
                <span class="bb"><?php echo $borrow['publish_remark'];?></span>
            </div>
            <?php }?>
		</div>
		<div class="zhanghu tab-con"  style="display: none;">
        
			<div>
				<h5 class="h51">账户信息：</h5>
				<span>借款总额：&yen;<?php echo number_format($user_borrow_account1['accounta'],2);?></span>
				<span>已还总额：&yen;<?php echo number_format($user_borrow_account1['account1'],2);?></span>
				<span>待还总额：&yen;<?php echo number_format($user_borrow_account1['account0'],2);?></span>
				<span>授信额度：&yen;<?php echo number_format($user_amount['credit'],2);?></span>
				<span>剩余额度：&yen;<?php echo number_format($user_amount['credit_use'],2);?></span>
				<span>网站垫付：&yen;0.00</span>
				<i> 注：公开的账户资金详情在标的借款全部还清后将自动不再公开显示。</i>
			</div>
			<div class="h51">
				<h5 class="h52">还款信用：</h5>
                <section>
				<span>借款 <?php echo $user_borrow_num['num0'];?> 次成功</span>
				<span><?php echo $user_borrow_num['num2'];?> 次流标</span>
				<span><?php echo $user_borrow_num['num1'];?> 笔待还款</span>
				<span>0 笔提前还款</span>
				<span><?php echo $user_borrow_num['num3'];?> 笔准时还款</span>
				<span>0 笔迟到还款</span>
				<span>0 笔30天之内的逾期还款</span>
				<span>0 笔超过30天的逾期还款0笔</span>
				<span>0 笔逾期未还款</span>
                </section>
			</div>
			<div>
				<h5 class="h52"><?php echo $borrow['ftype']==3 ? '待收记录':'待还记录';?>：</h5>
                <section>
                <?php if ($borrow['ftype']==3){?>
				<span style="width:270px;">标题</span>
				<span style="width:270px;">期数</span>
				<span style="width:270px;">应收金额</span>
				<span style="width:270px;">应收时间</span>
                <?php foreach($collection_list as $col){?>
                <span style="width:270px;"><?php echo utf8substr($col['title'],0,15);?></span>
                <span style="width:270px;"><?php echo $col['forder']+1;?>/<?php echo $col['time_limit'];?></span>
                <span style="width:270px;"><?php echo number_format($col['capital']+$col['interest'],2);?>元</span>
                <span style="width:270px;"><?php echo date('Y-m-d',$col['repay_time']);?></span>
                <?php }?>
                <?php }else{?>
				<span style="width:270px;">借款标题</span>
				<span style="width:270px;">期数</span>
				<span style="width:270px;">还款本息</span>
				<span style="width:270px;">实际到期日期</span>
                <?php foreach($user_borrow_repayment as $repayment){?>
                <span style="width:270px;"><?php echo utf8substr($repayment['title'],0,10);?></span>
                <span style="width:270px;"><?php echo $repayment['forder']+1;?>/<?php echo $repayment['time_limit'];?></span>
                <span style="width:270px;"><?php echo number_format($repayment['repayment_account'],2);?>元</span>
                <span style="width:270px;"><?php echo date('Y-m-d', $repayment['repayment_time']);?></span>
                <?php }?>
                <?php foreach($user_lz_borrow_repayment as $repayment){?>
                <span style="width:270px;"><?php echo utf8substr($repayment['title'],0,10);?></span>
                <span style="width:270px;"><?php echo $repayment['time_limit'];?>个月(流转周期)</span>
                <span style="width:270px;"><?php echo $repayment['account_yes'];?>元(流转中)</span>
                <span style="width:270px;"><?php echo date('Y-m-d', $repayment['lz_endtime']);?>(流转结束时间)</span>
                <?php }?>
                <?php }?>
                </section>
			</div>
		</div>
		<div class="toubiao tab-con" style="display: none;">
			<ul class="tbt">
				<li class="xmxq"><span>投资人/关系</span></li>
				<li class="nhsy">当前年利率</li>
				<li class="xmje">投标金额</li>
				<li class="bzfs">有效金额</li>
				<li class="qx">投标时间</li>
				<li class="jd">状态</li>
			</ul>
            <?php  foreach($borrow_tender_list as $borrow_tender){?>
            <?php if ($borrow_tender['account']>0 || $borrow_tender['money']){?>
			<ul class="tbc">
				<li class="xmxq"><span class="c_yh"><?php echo strdisplay_start($borrow_tender['username'], 2);?></span></li>
				<li class="nhsy"><span><b><?php echo $borrow['apr'];?></b>%</span></li>
				<li class="xmje"><span><?php echo number_format($borrow_tender['money'],2);?>元</span></li>
				<li class="bzfs"><span><?php echo number_format($borrow_tender['account'],2);?>元</span></li>
				<li class="qx"><span><?php echo date('Y-m-d H:i:s',$borrow_tender['add_time']);?></span></li>
				<li class="jd"><span>
				<?php if(($borrow_tender['money'] == $borrow_tender['account']) && $borrow_tender['fstatus'] != 3){?>
                已投标
				<?php }else if($borrow_tender['fstatus'] == 3){?>
                已撤回
                <?php }else{?>
                已投标
                <?php }?>
                </span></li>
            </ul>
			<?php }?>
			<?php }?>
        </div>
	</div>
</div> 
<div class="clear h20"></div>
<?php include './application/views/footer.php'; ?>
<script>
$(function () {
    $('#tab-list-li li').click(function () {
		var liindex = $('#tab-list-li li').index(this);
		$(this).addClass('cut').siblings().removeClass('cut');
		$('.linksQWap div.tab-con').eq(liindex).fadeIn(150).siblings('div.tab-con').hide();
	});
});
</script>
<script type="text/javascript">
	//即时剩余时间开始
	var SysSecond; 
	var InterValObj; 
	$(document).ready(function() { 
	 SysSecond = $("#remainSeconds").html(); //这里获取倒计时的起始时间 
	 InterValObj = window.setInterval(SetRemainTime, 1000); //间隔函数，1秒执行 
	}); 
	//将时间减去1秒，计算天、时、分、秒 
	function SetRemainTime() { 
	 if (SysSecond > 0) { 
	  SysSecond = SysSecond - 1; 
	  var second = Math.floor(SysSecond % 60);             // 计算秒     
	  var minite = Math.floor((SysSecond / 60) % 60);      //计算分 
	  var hour = Math.floor((SysSecond / 3600) % 24);      //计算小时 
	  var day = Math.floor((SysSecond / 3600) / 24);        //计算天 
	  $("#remainTime").html(day + "天" + hour + "小时" + minite + "分" + second + "秒"); 
	 } else {//剩余时间小于或等于0的时候，就停止间隔函数 
	  window.clearInterval(InterValObj); 
	  //这里可以添加倒计时时间为0后需要执行的事件 
	 } 
	} 
	//剩余时间结束

    function remain_time(iTime){
        var iDay,iHour,iMinute,iSecond;
        var sDay="",sTime="";
        if (iTime >= 0){
            iDay = parseInt(iTime/24/3600);
            iHour = parseInt((iTime/3600)%24);
            iMinute = parseInt((iTime/60)%60);
            iSecond = parseInt(iTime%60);

            if (iDay > 0){
                sDay = iDay + "天";
            }
            sTime =sDay + iHour + "小时" + iMinute + "分钟" + iSecond + "秒";
            if(iTime==0){
                sTime="<span style='color:green'>时间到了！</span>";
            }
            iTime=iTime-1;
        }else{
            sTime="<span style='color:red'>此标已过期！</span>";
        }
        $("#endtime").html(sTime);
    }
	<?php if ($borrow['ftype']==4){?>
	var url = "/borrow/lz_tender.html";
	<?php }elseif ($borrow['ftype']==6){?>
	var url = "/borrow/slinvest.html";
	<?php }elseif ($borrow['ftype']<8){?>
	var url = "/borrow/tender.html";
	<?php }?>
	function invest(){
		$.ajax({
		type: "POST",
		url: url,
		data: {id:$('#bid').val(),account:$('#account').val(),paypassword:$('#paypassword').val(),dxb_pwd:$('#dxb_pwd').val()},
		success: function(msg){
			if(msg=='1'){
				alert("投标成功");
				window.location.reload();
			}else{
				alert(msg);
			}
		},
		dataType: "text"});
	}
</script>